<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"
    import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head><title>瀏覽會員</title></head>
    <body>
    <% if(session.getAttribute("access") == "y" ){%>
    <jsp:useBean id="mydb" scope="page" class="bean.ConDbBean"/> <%//連結資料庫的bean %>
   <%
    String sql;
        sql = "SELECT * from MEMBER";
        ResultSet rs = mydb.executeQuery(sql);

        out.println("列出會員資料<hr>");
        out.println("<table border = '1'>");
        out.println("<tr>"+
        "<th>編號</th><th>帳號</th><th>姓名</th><th>部門</th></tr>");
        
        while(rs.next()){
            out.println("<tr><td>" + rs.getString(1) +
            "</td><td>" + rs.getString(2) +
            "</td><td>" + rs.getString(3) +
            "</td><td>" + rs.getString(10) + "</td></tr>" );
        }
        
    %>
    <%
  }
  else{
  	response.sendRedirect("../index.jsp"); //若沒有登入則回到index.jsp
  } 
  %>
    </body>
</html>